package com.axonactive.yolo.service.internal;

import java.io.IOException;

import org.json.simple.parser.ParseException;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.axonactive.yolo.exception.ExchangeRateNotFoundException;
import com.axonactive.yolo.monitor.UpdateExchangeRate;

public class QuartzJobUpdateExchangeRate extends QuartzJobBean {
	private UpdateExchangeRate updateExchangeRate;

	public void setUpdateExchangeRate(UpdateExchangeRate updateExchangeRate) {
		this.updateExchangeRate = updateExchangeRate;
	}

	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
		try {
			updateExchangeRate.run();
		} catch (ExchangeRateNotFoundException | IOException | ParseException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
